package com.redside.webapp.util;

import java.beans.PropertyEditorSupport;

import com.redside.model.lookup.StateLkp;
import com.redside.service.OptionsBeanLookupManager;

public class CustomStateEditor  extends PropertyEditorSupport {
 
    private final OptionsBeanLookupManager optionsBeanManager;
 
    public CustomStateEditor(OptionsBeanLookupManager optionsBeanLookupDao) {
        this.optionsBeanManager = optionsBeanLookupDao;
    }
 
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
    	//TODO fix to get value from text field
    	StateLkp lkp = new StateLkp("OR", "OR");
        setValue(lkp);
    }
 
    @Override
    public String getAsText() {
    	StateLkp s = (StateLkp) getValue();
        if (s == null) {
            return null;
        } else {
            return s.getStateId();
        }
    }
}